#include "test.h"

test::test(QObject *parent) : QObject(parent)
{

}
void test::Run(int port){
    listenSocket = new QTcpServer();
    listenSocket->listen(QHostAddress::Any,port);
    QObject::connect(listenSocket,SIGNAL(newConnection()),this,SLOT(processConnection()));

}
void test::processConnection(){
    this->readWriteSocket =this->listenSocket->nextPendingConnection();
    QObject::connect(readWriteSocket,SIGNAL(readyRead()),this,SLOT(processText()));
}

void test::processText(){
    std::cout << this->readWriteSocket->readAll().toStdString() << std::endl;
    readWriteSocket->write(this->readWriteSocket->readAll());
}
